//
//  ST_LittleLuckTipsCell.swift
//  btvideo
//
//  Created by mac on 2020/12/30.
//  Copyright © 2020 JarvanZhang. All rights reserved.
//

import UIKit
import SwiftyAttributes


class ST_LittleLuckTipsCell: UITableViewCell {

    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = .none
        self.contentView.backgroundColor = UIColor.white
    
        
        contentView.addSubview(gray_background_view)
        gray_background_view.snp.makeConstraints { (make) in
            make.edges.equalToSuperview().inset(UIEdgeInsets.init(top: 15, left: 15, bottom: 16, right: 15))
        }
        
        
        gray_background_view.addSubview(label)
        label.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(15)
            make.top.equalToSuperview().offset(15)
            make.right.equalToSuperview().offset(-15)
//            make.height.equalTo(40)
        }
        
        gray_background_view.addSubview(btn1)
        btn1.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(15)
            make.height.equalTo(40)
            make.bottom.equalToSuperview().offset(-5)
        }

//        gray_background_view.addSubview(btn0)
//        btn0.snp.makeConstraints { (make) in
//            make.left.equalToSuperview().offset(15)
//            make.height.equalTo(18)
//            make.bottom.equalTo(btn1.snp.top).offset(-5)
//        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    fileprivate lazy var gray_background_view:UIView = {
       let control = UIView()
        control.backgroundColor = UIColor.init(hex: 0xF5F8FA)
        control.cornerRadius = 15
        return control
    }()
    
    
    fileprivate lazy var label:UILabel = {
       
        let control = UILabel()
        
        control.numberOfLines = 0
        
        return control
    }()
    
//    fileprivate lazy var btn0:UIButton = {
//
//        let control = UIButton.init(type: UIButton.ButtonType.custom)
//
//        control.setTitleForAllStates("点击语音通话")
//
//        control.titleLabel?.font = UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.semibold)
//
//        control.setTitleColorForAllStates(UIColor.init(hex: 0xFEC207)!)
//
//        control.addTarget(self, action: #selector(voiceHandle), for: UIControl.Event.touchUpInside)
//
//        return control
//    }()
    
    
    fileprivate lazy var btn1:UIButton = {
        
        let control = UIButton.init(type: UIButton.ButtonType.custom)
        
        control.setTitleForAllStates("点击开始通话")
        
        control.titleLabel?.font = UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.semibold)
        
        control.setTitleColorForAllStates(UIColor.init(hex: 0xFEC207)!)
        
        control.addTarget(self, action: #selector(videoHandle), for: UIControl.Event.touchUpInside)
        
        return control
    }()
    
//    var voiceChatClosure:(()->())?
//    @objc fileprivate func voiceHandle(){
//
//        btn0.isUserInteractionEnabled = false
//
//        main_thread_execute(afterDelay: 1.5) {
//            self.btn0.isUserInteractionEnabled = true
//        }
//
//        voiceChatClosure?()
//    }
    
    
    var video_chat_closure:(()->())?
    @objc fileprivate func videoHandle(){
        
        btn1.isUserInteractionEnabled = false
        
        main_thread_execute(afterDelay: 1.5) {
            self.btn1.isUserInteractionEnabled = true
        }
        
        video_chat_closure?()
    }
    
    
    var message:ST_DTChatMessage! {
        didSet{
            
            label.attributedText = message.littleLuckTips
            
        }
    }
   
}
